{extend name="layout" /}
{block name="body"}
<div class="row">
    <div class="col-lg-12">
        <div class="card">
            <div class="card-body">
                <div class="media">
                    <img id="adminnewtx1" src="http://q1.qlogo.cn/g?b=qq&nk={$admininfo['adminqq']}&s=640" width="64px"
                        class="img-avatar mr-3">
                    <div class="media-body">
                        <p class="mt-1 mb-0">自动获取QQ头像为此系统的头像</p>
                    </div>
                </div>
                <hr>
                <form class="site-form">
                    <div class="form-group">
                        <label for="adminname">用户名</label>
                        <input type="text" class="form-control" name="adminname" id="adminname"
                            value="{$admininfo['adminname']}">
                    </div>
                    <div class="form-group">
                        <label for="nickname">昵称</label>
                        <input type="text" class="form-control" name="nickname" id="nickname" placeholder="输入您的昵称"
                            value="{$admininfo['nickname']}">
                    </div>
                    <div class="form-group">
                        <label for="adminqq">QQ</label>
                        <input type="number" class="form-control" name="adminqq" id="adminqq"
                            aria-describedby="emailHelp" placeholder="请输入正确的qq" value="{$admininfo['adminqq']}">
                        <small id="emailHelp" class="form-text text-muted">请保证您填写的qq是正确的。</small>
                    </div>
                    <button type="button" id="admininfoedit" class="btn btn-primary">保存</button>
                </form>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="js"}
<script>
    $("#admininfoedit").click(function () {
        var l = $('body').lyearloading({
            opacity: 0.2,
            spinnerSize: 'lg'
        });
        $.ajax({
            type: 'post',
            url: "{:url('admin/admininfo')}",
            data: $("form").serialize(),
            dataType: "json",
            success: function (data) {
                l.destroy();
                if (data.code == 1) {
                    notify.success(data.msg, function () {
                        location.reload();
                    }, 1000);
                } else {
                    notify.error(data.msg);
                }
            },
            error: function () {
                l.destroy();
                notify.error("服务器错误");
            }
        })
    })
</script>
{/block}